﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designer.Views
{
    public partial class ViewHistoryWindow
    {
        [Common.Subscribe]
        public void OnEndGetItemHistoryListEvent(Event.NCL.EndGetItemHistoryListEvent @event)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (@event.State == Event.NCL.NCLEventState.Finished)
                {
                    if (@event.List != null && @event.List.Length > 0)
                    {
                        foreach (var item in @event.List.OrderByDescending(p => p.OperatedTime))
                        {
                            ItemHistory history = new ItemHistory((ServiceProxy.DesignServiceRef.ItemHistory)item);
                            this._ctlHistoryListView.Items.Add(history);
                        }
                    }
                }
            });
        }
    }
}
